package com.pig4cloud.pigx.user.api.feign;

import com.pig4cloud.pigx.common.core.constant.SecurityConstants;
import com.pig4cloud.pigx.common.core.constant.ServiceNameConstants;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.user.dto.UpdateFuelBalanceDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;

/**
 * 用户模块-燃料账户feign接口
 *
 */
@FeignClient(contextId = "fuelAccountFeign",
        value = ServiceNameConstants.USER_SERVICE,
        path = "/feign/fuel_account")
public interface FuelAccountFeign {

    /**
     * 修改燃料账户余额
     *
     * @param dto  dto
     * @param from from
     * @return r
     */
    @PutMapping("/balance")
    BigDecimal updateBalance(@RequestBody UpdateFuelBalanceDTO dto, @RequestHeader(SecurityConstants.FROM) String from);

    /**
     * 查询用户燃料账户额度
     *
     * @param userId 用户id
     * @param from   标记内部请求
     * @return {@link R< BigDecimal>}
     * @since 2022/12/10 15:38
     */
    @GetMapping("/balance")
    R<BigDecimal> getBalance(@RequestParam("userId") Long userId, @RequestHeader(SecurityConstants.FROM) String from);

}
